Skip to content

Refresh button width adaptation#1387

Draft
ivanortegaalba wants to merge 5 commits intomainfrom
cursor/refresh-button-width-adaptation-2627
Draft

Refresh button width adaptation#1387
ivanortegaalba wants to merge 5 commits intomainfrom
cursor/refresh-button-width-adaptation-2627

Conversation

@ivanortegaalba
Copy link
Copy Markdown
Collaborator

Replaces the fixed width of the SceneRefreshPicker button with a dynamic width solution to support multi-language labels and prevent layout shifts when toggling between refresh and cancel states.

The original issue (grafana/grafana#119789) reported that the fixed 96px width caused text truncation for longer labels (e.g., German) and layout shifts. This PR introduces a CSS inline-grid container where both the visible RefreshPicker and a hidden RefreshPicker (displaying the alternate text) occupy the same grid cell. This ensures the button's width always accommodates the longest possible label, preventing truncation and layout shifts. The hidden instance uses visibility: hidden and pointer-events: none to be inert.


Open in Web Open in Cursor 

Replace the fixed 96px width with a CSS grid-based approach that renders
both the active and alternate label text (e.g. Refresh/Cancel), with the
alternate hidden via visibility:hidden. This ensures the button always
takes the width of the longest label, preventing layout shifts when
toggling between states and supporting variable-length translations.

Fixes grafana/grafana#119789

Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>
@cursor
Copy link
Copy Markdown

cursor bot commented Mar 9, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

cursoragent and others added 4 commits March 9, 2026 12:25
Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>
Remove the hard-coded width='96px' that was applied when withText is
enabled. The button now naturally sizes to its text content, which
correctly handles translations of any length without truncation.

Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>
Render both the refresh and cancel labels as overlapping spans inside an
inline-grid container, toggling visibility based on the running state.
This ensures the button always takes the width of the longest label,
preventing layout shifts when toggling and adapting to any translation.

Removes the fixed 96px width that caused truncation in longer languages.

Fixes grafana/grafana#119789

Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>
Both labels overlap in the same grid cell via gridArea:'1/1', toggling
visibility. The cell width equals the wider label, so the button never
changes size when switching states.

Replaces the fixed 96px width and works with any translation length.

Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants